package com.z.platform.actingModel;

import org.apache.commons.lang3.time.StopWatch;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

public class DemoProxy implements InvocationHandler {
    private Object target;

    public void setTarget(Object target) {
        this.target = target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //创建并启动StopWatch
        StopWatch stopwatch = StopWatch.createStarted();
        System.out.println("我要起飞啦");
        Object invoke = method.invoke(target, args);
//        Thread.sleep(3000);
        stopwatch.stop();
        System.out.println(stopwatch.getTime(TimeUnit.MINUTES));
        return invoke;

    }
}

